#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
#define rep(i,l,r) for(int i=(l),i##end=(r);i<=i##end;++i)
#define per(i,r,l) for(int i=(r),i##end=(l);i>=i##end;--i)
#define ll long long
//#define int ll
#define double long double
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define popcnt __builtin_popcount
#define rbtree(way) tree<way,null_type,less<way>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
class IO{
    char ibuf[1<<16],obuf[1<<16],*ipl=ibuf,*ipr=ibuf,*op=obuf;
    public:
    ~IO(){write();}
    inline void read(){ipl==ipr?ipr=(ipl=ibuf)+fread(ibuf,1,1<<15,stdin):0;}
    inline void write(){fwrite(obuf,1,op-obuf,stdout),op=obuf;}
    inline char getchar(){return (read(),ipl!=ipr)?*ipl++:EOF;}
    inline void putchar(char c){*op++=c;if(op-obuf>(1<<15)) write();}
    template<typename V>IO&operator>>(V&v){
        int s=1;char c=getchar();v=0;
        for(;!isdigit(c);c=getchar()) if(c=='-') s=-s;
        for(;isdigit(c);c=getchar()) v=(v<<1)+(v<<3)+(c^48);
        return v*=s,*this;
    }
    inline IO&operator<<(char c){return putchar(c),*this;}
    template<typename V>IO&operator<<(V v){
        if(!v) putchar('0');
		if(v<0) putchar('-'),v=-v;
        char stk[100],*top=stk;
        for(;v;v/=10) *++top=v%10+'0';
        while(top!=stk) putchar(*top--);
		return *this;
    }
}io;
//#define cin io
//#define cout io
#define Tie (ios::sync_with_stdio(0),cin.tie(0),cout.tie(0))
const int maxn=(1<<20)+10,maxm=1e6+10,mod=998244353,inf=INT_MAX;
inline int ksm(int x,int k,int mod=mod){
	int ans=1;
	for(x%=mod;k;k>>=1,x=x*x%mod) if(k&1) ans=ans*x%mod;
	return ans;
}

int n,ans,tot=1,tr[maxn<<1][2],t[maxn<<1][22],fa[maxn<<1],ed[maxn<<1];
string s[maxn];

inline void update(int x,int c){
	int nw=x;
	rep(i,0,20) if(nw) t[nw][i]+=c,nw=fa[nw];
}
void down(int x,int fl){
	if(fl&&ed[x]==1||!ed[x]) return;
//	cerr<<x<<','<<ed[x]<<']'<<'\n';
	rep(i,1,ed[x]){
		rep(j,1,20) if(t[x][j]!=(1<<j)){
			if(t[tr[x][0]][j-1]!=(1<<j-1)){
//				cout<<x<<','<<i<<'a'<<'}';
				int fl=0;
				if(!tr[x][0]) fa[tr[x][0]=++tot]=x,update(tot,1),fl=1;
				++ed[tr[x][0]],++ans,down(tr[x][0],fl);
			}
			else{
//				cout<<x<<','<<i<<'b'<<'}';
				int fl=0;
				if(!tr[x][1]) fa[tr[x][1]=++tot]=x,update(tot,1),fl=1;
				++ed[tr[x][1]],++ans,down(tr[x][1],fl);
			}
			j=jend;
		}
	}
	ed[x]=0;
}
inline void insert(string s){
	int nw=1;
	for(char c:s){
		if(!tr[nw][c-'0']) fa[tr[nw][c-'0']=++tot]=nw,update(tot,1);
		nw=tr[nw][c-'0'];
	}
	++ed[nw];
}
int dfs(int x){
	if(!x) return 0;
	int fl0=dfs(tr[x][0]),fl1=dfs(tr[x][1]);
	if((fl0||fl1)&&ed[x]||ed[x]>1) return down(x,0),1;
	return ed[x]|fl0|fl1;
}

signed main(){
	freopen("id.in","r",stdin),freopen("id.out","w",stdout);
	Tie;
	cin>>n;
	rep(i,1,n) cin>>s[i],insert(s[i]);
	dfs(1),cout<<ans;
	return 0;
}/*
5
01
01
01
011
0100

*/
